package cn.xscrum.demo.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.xscrum.common.annotation.Log;
import cn.xscrum.common.enums.BusinessType;
import cn.xscrum.demo.domain.UrbanRailOperation;
import cn.xscrum.demo.service.IUrbanRailOperationService;
import cn.xscrum.common.core.controller.BaseController;
import cn.xscrum.common.core.domain.AjaxResult;
import cn.xscrum.common.utils.poi.ExcelUtil;
import cn.xscrum.common.core.page.TableDataInfo;

/**
 * 换乘轨道城市数据分析Controller
 * 
 * @author xscrum
 * @date 2020-11-25
 */
@Controller
@RequestMapping("/demo/operation")
public class UrbanRailOperationController extends BaseController
{
    private String prefix = "demo/operation";

    @Autowired
    private IUrbanRailOperationService urbanRailOperationService;

    @RequiresPermissions("demo:operation:view")
    @GetMapping()
    public String operation()
    {
        return prefix + "/operation";
    }

    /**
	 * 查询换乘轨道城市数据分析列表
     */
    @RequiresPermissions("demo:operation:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(UrbanRailOperation urbanRailOperation)
    {
        startPage();
        List<UrbanRailOperation> list = urbanRailOperationService.selectUrbanRailOperationList(urbanRailOperation);
        return getDataTable(list);
    }

    /**
	 * 导出换乘轨道城市数据分析列表
     */
    @RequiresPermissions("demo:operation:export")
    @Log(title = "换乘轨道城市数据分析", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(UrbanRailOperation urbanRailOperation)
    {
        List<UrbanRailOperation> list = urbanRailOperationService.selectUrbanRailOperationList(urbanRailOperation);
        ExcelUtil<UrbanRailOperation> util = new ExcelUtil<UrbanRailOperation>(UrbanRailOperation.class);
        return util.exportExcel(list, "operation");
    }

    /**
	 * 新增换乘轨道城市数据分析
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
	 * 新增保存换乘轨道城市数据分析
     */
    @RequiresPermissions("demo:operation:add")
    @Log(title = "换乘轨道城市数据分析", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(UrbanRailOperation urbanRailOperation)
    {
        return toAjax(urbanRailOperationService.insertUrbanRailOperation(urbanRailOperation));
    }

    /**
	 * 修改换乘轨道城市数据分析
     */
    @GetMapping("/edit/{no2}")
    public String edit(@PathVariable("no2") Long no2, ModelMap mmap)
    {
        UrbanRailOperation urbanRailOperation = urbanRailOperationService.selectUrbanRailOperationById(no2);
        mmap.put("urbanRailOperation", urbanRailOperation);
        return prefix + "/edit";
    }

    /**
	 * 修改保存换乘轨道城市数据分析
     */
    @RequiresPermissions("demo:operation:edit")
    @Log(title = "换乘轨道城市数据分析", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(UrbanRailOperation urbanRailOperation)
    {
        return toAjax(urbanRailOperationService.updateUrbanRailOperation(urbanRailOperation));
    }

    /**
	 * 删除换乘轨道城市数据分析
     */
    @RequiresPermissions("demo:operation:remove")
    @Log(title = "换乘轨道城市数据分析", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(urbanRailOperationService.deleteUrbanRailOperationByIds(ids));
    }
}
